/* AI聊天页面样式 */
.ai-container {
  display: flex;
  height: 100vh;
  background-color: #f5f5f5;
}

/* 侧边栏样式 */
.sidebar {
  width: 280px;
  background-color: #fff;
  border-right: 1px solid #e8e8e8;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.sidebar-visible {
  transform: translateX(0);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #e8e8e8;
  display: flex;
  align-items: center;
  gap: 12px;
}

.new-chat-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.new-chat-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.new-chat-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.new-chat-icon {
  font-size: 16px;
  font-weight: bold;
}

.sidebar-toggle {
  width: 36px;
  height: 36px;
  border: 1px solid #e8e8e8;
  background-color: #fff;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.sidebar-toggle:hover {
  background-color: #f5f5f5;
  border-color: #d9d9d9;
}

.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.session-item {
  display: flex;
  align-items: center;
  padding: 12px;
  margin-bottom: 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.session-item:hover {
  background-color: #f5f5f5;
}

.session-active {
  background-color: #e6f7ff;
  border: 1px solid #91d5ff;
}

.session-content {
  flex: 1;
  min-width: 0;
}

.session-title {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-time {
  font-size: 12px;
  color: #999;
}

.delete-session-btn {
  width: 24px;
  height: 24px;
  border: none;
  background-color: transparent;
  color: #999;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.3s ease;
  opacity: 0;
}

.session-item:hover .delete-session-btn {
  opacity: 1;
}

.delete-session-btn:hover {
  background-color: #ff4d4f;
  color: white;
}

/* 遮罩层 */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: none;
}

/* 响应式设计 - 侧边栏 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transform: translateX(-100%);
  }
  
  .sidebar-visible {
    transform: translateX(0);
  }
  
  .sidebar-overlay {
    display: block;
  }
  
  .ai-page {
    margin: 0;
    height: 100vh;
    max-width: none;
  }
}

.ai-page {
  display: flex;
  flex-direction: column;
  height: 80vh;
  max-width: 800px;
  margin: 20px auto;
  background-color: #f5f5f5;
  position: relative;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  flex: 1;
}

.drag-over {
  background-color: rgba(24, 144, 255, 0.1);
}

.drag-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(24, 144, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border: 2px dashed #1890ff;
}

.drag-message {
  text-align: center;
  color: #1890ff;
  font-size: 18px;
  font-weight: bold;
}

.drag-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
}

/* 聊天头部 */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: #fff;
  border-bottom: 1px solid #e8e8e8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-radius: 12px 12px 0 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-sidebar-toggle {
  width: 32px;
  height: 32px;
  border: 1px solid #e8e8e8;
  background-color: #f0f0f0;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.mobile-sidebar-toggle:hover {
  background-color: #e0e0e0;
}

@media (min-width: 769px) {
  .mobile-sidebar-toggle {
    display: none;
  }
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #f0f0f0;
  cursor: pointer;
  transition: all 0.3s ease;
}

.back-btn:hover {
  background-color: #e0e0e0;
}

.back-icon {
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

.header-title {
  font-size: 16px;
  font-weight: bold;
  color: #333;
}

.header-shortcuts {
  font-size: 12px;
  color: #666;
}

.shortcut-hint {
  background-color: #f0f0f0;
  padding: 4px 8px;
  border-radius: 4px;
}

/* 聊天内容区域 */
.chat-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background-color: #f5f5f5;
}

.message-row {
  margin-bottom: 16px;
  display: flex;
}

.user-row {
  justify-content: flex-end;
}

.ai-row {
  justify-content: flex-start;
}

.bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  word-wrap: break-word;
  position: relative;
}

.user-bubble {
  background-color: #1890ff;
  color: white;
  margin-left: auto;
}

.ai-bubble {
  background-color: white;
  color: #333;
  border: 1px solid #e8e8e8;
  margin-right: auto;
}

/* 打字指示器 */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #1890ff;
  margin: 0 2px;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background-color: #1890ff;
  margin-left: 4px;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

/* AI操作按钮 */
.ai-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.ai-action-btn {
  padding: 4px 8px;
  background-color: #f0f0f0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.3s ease;
}

.ai-action-btn:hover {
  background-color: #e0e0e0;
}

/* 文件上传区域 */
.uploaded-files {
  background-color: white;
  border-top: 1px solid #e8e8e8;
  padding: 12px 16px;
}

.files-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: bold;
  color: #333;
}

.clear-files-btn {
  background: none;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
  color: #666;
}

.clear-files-btn:hover {
  border-color: #1890ff;
  color: #1890ff;
}

.files-list {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.file-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  background-color: #f9f9f9;
  border-radius: 8px;
  padding: 8px;
  border: 1px solid #e8e8e8;
}

.file-preview {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 4px;
}

.document-preview {
  background-color: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #666;
}

.file-info {
  text-align: center;
  font-size: 12px;
}

.file-name {
  display: block;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #333;
}

.file-size {
  display: block;
  color: #666;
  margin-top: 2px;
}

.remove-file-btn {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: #ff4d4f;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 输入栏 */
.chat-input-bar {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background-color: white;
  border-top: 1px solid #e8e8e8;
  gap: 10px;
  border-radius: 0 0 12px 12px;
}

.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #f0f0f0;
  cursor: pointer;
  transition: all 0.3s ease;
}

.upload-btn:hover {
  background-color: #e0e0e0;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d9d9d9;
  border-radius: 18px;
  outline: none;
  font-size: 14px;
  resize: none;
  min-height: 18px;
  max-height: 80px;
}

.chat-input:focus {
  border-color: #1890ff;
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.send-btn {
  padding: 10px 16px;
  background-color: #1890ff;
  color: white;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.send-btn:hover {
  background-color: #40a9ff;
}

.send-btn:disabled {
  background-color: #d9d9d9;
  cursor: not-allowed;
}

.stop-btn {
  padding: 10px 16px;
  background-color: #ff4d4f;
  color: white;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.stop-btn:hover {
  background-color: #ff7875;
}

.interrupted-message {
  color: #ff4d4f;
  font-style: italic;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .ai-page {
    height: 90vh;
    margin: 10px;
    max-width: none;
  }
  
  .chat-header {
    padding: 10px 12px;
  }
  
  .chat-content {
    padding: 12px;
  }
  
  .bubble {
    max-width: 85%;
  }
  
  .chat-input-bar {
    padding: 10px 12px;
  }
  
  .header-shortcuts {
    display: none;
  }
}